package com.customer.crm.system.controller;

import com.customer.crm.system.pojo.Menu;
import com.customer.crm.system.pojo.SystemFunction;
import com.customer.crm.system.pojo.SystemUser;
import com.customer.crm.system.service.MenuService;
import com.customer.crm.system.service.SystemFunctionService;
import com.customer.crm.system.service.SystemRoleService;
import com.customer.crm.system.service.SystemUserService;
import com.customer.crm.util.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Lyp
 * @create 2021/12/16
 */

@Controller
public class MenuController extends  BaseController{


    @Autowired
    private SystemUserService systemUserService;

    @Autowired
    private  MenuService menuService;

    @RequestMapping("system/index_menu")
    @ResponseBody
    public ResultData menu(HttpSession session , Model model , HttpServletResponse response ) throws IOException {

        SystemUser systemUser = (SystemUser) session.getAttribute("systemUser");

        List<Menu> menus = menuService.findMenu(systemUser);

        resultData = ResultData.buildSuccessResult("加载成功" , menus);
//        printJSONObject(resultData , response);
        return  resultData;
    }

}
